<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\DailyReportStatistics;
use Carbon\Carbon;
use Illuminate\Http\Request;

class IndexController extends Controller
{
    public function dailyStatistics(Request $request)
    {
        return $this->response->array(
            DailyReportStatistics::query()
                ->whereBetween('date', [
                    $request->get('begin', Carbon::today()->subDays(7)->format('Y-m-d')), // 统计上线日
                    $request->get('end', Carbon::today()->format('Y-m-d'))
                ])
                ->select([
                    'date',
                    'number_of_group_owner_order', 'number_of_elite_order', 'number_of_strongman_order',
                    'number_of_group_owner_place_order', 'number_of_elite_place_order', 'number_of_strongman_place_order',
                    'group_owner_performance_summary', 'elite_performance_summary', 'strongman_performance_summary',
                    'group_owner_uv', 'elite_uv', 'strongman_uv',
                    'total_number_of_before_agents', 'total_number_of_new_agents'
                ])
                ->orderBy('date')
                ->get()
                ->toArray()
        );
    }
}
